<template>
  <my-simple-page
    :create-enable="false"
    :edit-enable="false"
    :search-fields="searchFields"
    :tableTitle="tableTitle"
    :columns="columns"
    :search-url="searchUrl"
    :delete-url="deleteUrl"
    @rowClick="rowClick">
  </my-simple-page>
</template>

<script>
  export default {
    name: "knowledge-index",
    data(){
      return{
        searchFields: [
          {
            type: 'input',
            label: '关键词',
            prop: 'content'
          }
        ],
        tableTitle: '知识列表',
        columns: [
          {label:'标题',prop: 'title',width: '200'},
          {label:'类型',prop: 'type',width: '100',render: this.renderType},
          {label:'内容',prop: 'content'}],
        searchUrl: '/api/study/article/getArticleList',
        deleteUrl: '/api/study/article/deleteArticle',
        typeDict: [],
      }
    },
    methods:{
      rowClick(row){
        this.$router.push({path: `/articleDetail/${row.id}`})
      },
      renderType(val){
        for(let item of this.typeDict){
          if (item.value == val){
            return item.label;
          }
        }
      },
    },
    created() {
      this.$ajax.getDict('ARTICLE_TYPE_DICT').then(res=>{
        this.typeDict = res;
      })
    }
  }
</script>

<style scoped>

</style>
